<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>

</body>

</html>
<script>
    let obj = {
        name: "李四",
        sex: "男"
    }

    Object.prototype[Symbol.iterator] = function () {
        const keys = Object.keys(this);
        //["name","sex"]
        let index = 0
        const _this = this
        return {
            next() {
                return {
                    value: _this[keys[index++]],
                    done: index > keys.length
                }
            }
        }
    }
    
    for (let i of obj) {
        console.log(i)
    }
</script>